/*
 * webPanel.java
 *
 * Created on 2008年5月28日, 上午11:43
 */

package gui;

import configure.ConfigureInfo;
import java.awt.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jdesktop.jdic.browser.WebBrowser;

/**
 *
 * @author  yux
 */
public class webPanel extends javax.swing.JPanel {
    private WebBrowser webBrowser=null;
    /** Creates new form webPanel */
    public webPanel() {
        super();
        try {
            //initComponents();
            webBrowser = new WebBrowser();
            webBrowser.setURL(new URL(ConfigureInfo.getProperty(ConfigureInfo.InfoURL)));
            this.setLayout(new BorderLayout());
            this.setPreferredSize(new Dimension(700, 500));
            this.add(webBrowser, BorderLayout.CENTER);
            new Thread(){
                @Override
                public void run() {
                    while(true) {
                        try {
                            webBrowser.setURL(new URL(ConfigureInfo.getProperty(ConfigureInfo.InfoURL)));
                            sleep(Integer.parseInt(ConfigureInfo.getProperty(ConfigureInfo.webRefreshingTime)));
                        } catch (MalformedURLException ex) {
                            Logger.getLogger(webPanel.class.getName()).log(Level.SEVERE, null, ex);
                        } catch (InterruptedException ex) {
                            Logger.getLogger(webPanel.class.getName()).log(Level.SEVERE, null, ex);
                        }
                    }
                }
            }.start();
            System.out.println("abc");
        } catch (MalformedURLException ex) {
            Logger.getLogger(webPanel.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    public void refresh() {
        try {
            webBrowser.setURL(new URL(ConfigureInfo.getProperty(ConfigureInfo.InfoURL)));
        } catch (MalformedURLException ex) {
            Logger.getLogger(webPanel.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 668, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 501, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
    
}
